package com.novatialabs.qttt.gwt.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * 
 * @author nchalko
 * 
 */
public class MoveListWidget extends Composite implements GameDisplayHandler {

  private final MoveWidget[] moves;
  private final TextArea textArea;
  private final Notation notation = new BaseNotation();

  public MoveListWidget() {
    VerticalPanel panel = new VerticalPanel();
    moves = new MoveWidget[9];
    for (int i = 0; i < moves.length; i++) {
      moves[i] = new MoveWidget(i + 1);
      panel.add(moves[i]);
    }
    textArea = new TextArea();
    textArea.setVisibleLines(10);
    panel.add(textArea);

    initWidget(panel);
  }

  public void display(GameDisplayEvent gameEvent) {
    GameModel game = gameEvent.getGame();
    String text = notation.printGame(game);
    textArea.setText(text);

  }

}
